package com.flyoil.petromp.ui.activity.activity_me;

import android.widget.TextView;

import com.cnpc.fyutils.ToastUtils;
import com.flyoil.petromp.Constant.ConstantNetworkCode;
import com.flyoil.petromp.R;
import com.flyoil.petromp.apiservice.HttpModel;
import com.flyoil.petromp.apiservice.OnObserverRetrofitResetCallBack;
import com.flyoil.petromp.base.BaseActivity;
import com.flyoil.petromp.base.BaseEntity;
import com.flyoil.petromp.entity.entity_me.UserMessageEntity;

/**
 * 个人信息详情界面
 */
public class UserMessageActivity extends BaseActivity {
    private TextView tv_userNumber;//编号
    private TextView tv_reallyName;//姓名
    private TextView tv_genderLabel;//性别
    private TextView tv_departmentName;//部门
    private TextView tv_position;//岗位/职务
    private TextView tv_professionalTitle;//职称
    private TextView tv_professionalRank;//职级
    private TextView tv_directSuperior;//直接上级
    private TextView tv_status;//状态
    private TextView tv_jobDescription;//职责描述
    private TextView tv_officePosition;//办公地点
    private TextView tv_office;//办公室
    private TextView tv_officePhone;//办公电话
    private TextView tv_phone;//移动电话
    private TextView tv_email;//电子邮箱

    @Override
    protected int getContentViewResId() {
        return R.layout.activity_user_message;
    }

    @Override
    protected void initViews() {
        super.initViews();
        setTextTitleName("基本信息");
        setBackOnclickListner(mContext);
        httpModel = new HttpModel();
        tv_userNumber = $(R.id.tv_userNumber);
        tv_reallyName = $(R.id.tv_reallyName);
        tv_genderLabel = $(R.id.tv_genderLabel);
        tv_departmentName = $(R.id.tv_departmentName);
        tv_position = $(R.id.tv_position);
        tv_professionalTitle = $(R.id.tv_professionalTitle);
        tv_professionalRank = $(R.id.tv_professionalRank);
        tv_directSuperior = $(R.id.tv_directSuperior);
        tv_status = $(R.id.tv_status);
        tv_jobDescription = $(R.id.tv_jobDescription);
        tv_officePosition = $(R.id.tv_officePosition);
        tv_office = $(R.id.tv_office);
        tv_officePhone = $(R.id.tv_officePhone);
        tv_phone = $(R.id.tv_phone);
        tv_email = $(R.id.tv_email);
    }

    @Override
    protected void initdatas() {
        super.initdatas();
        httpModel.getUserMessage(null, new OnObserverRetrofitResetCallBack<BaseEntity>() {
            @Override
            public void onSuccess(BaseEntity model) {
                super.onSuccess(model);
                UserMessageEntity entity = null;
                if (model instanceof UserMessageEntity)
                    entity = (UserMessageEntity) model;
                if (entity != null && entity.getCode() == ConstantNetworkCode.SuccedCode) {
                    tv_userNumber.setText(entity.getData().getUserNumber());
                    tv_reallyName.setText(entity.getData().getReallyName());
                    tv_genderLabel.setText(entity.getData().getGenderLabel());
                    tv_departmentName.setText(entity.getData().getDepartmentName());
                    tv_position.setText(entity.getData().getPosition());
                    tv_professionalTitle.setText(entity.getData().getProfessionalTitle());
                    tv_professionalRank.setText(entity.getData().getProfessionalRank());
                    tv_directSuperior.setText(entity.getData().getDirectSuperior());
                    tv_status.setText(entity.getData().getStatus());
                    tv_jobDescription.setText(entity.getData().getJobDescription());
                    tv_officePosition.setText(entity.getData().getOfficePosition());
                    tv_office.setText(entity.getData().getOffice());
                    tv_officePhone.setText(entity.getData().getOfficePhone());
                    tv_phone.setText(entity.getData().getPhone());
                    tv_email.setText(entity.getData().getEmail());
                } else {
                    ToastUtils.show_toast(model.getMessage());
                }
            }

            @Override
            public void onFailure(String msg) {
            }
        });
    }
}
